package com.jd.ty.pojo;

import java.io.Serializable;

public class Permission  implements Serializable, Comparable<Permission> {
	private static final long serialVersionUID = -3310258685203725117L;

	private Long permissionId;
	private Role role;
	private Function function;
	private Long permission = 1L;

	public Permission() {
	}

	public void linkToRole(Role role) {
		setRole(role);
		role.getPermissions().add(this);
	}

	public void unlinkRole() {
		role.getPermissions().remove(this);
		setRole(null);
	}

	public Long getPermissionId() {
		return permissionId;
	}

	public void setPermissionId(Long permissionId) {
		this.permissionId = permissionId;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Function getFunction() {
		return function;
	}

	public void setFunction(Function function) {
		this.function = function;
	}

	public Long getPermission() {
		return permission;
	}

	public void setPermission(Long permission) {
		this.permission = permission;
	}
	public int compareTo(Permission obj) {
		return this.getFunction().getFunctionId().compareTo(obj.getFunction().getFunctionId());
	}
}
